package com.amt.olcacon.controller.init;

import com.amt.olcacon.db.DerbyConfig;
import lombok.extern.slf4j.Slf4j;
import org.openlca.core.DataDir;
import org.openlca.core.database.upgrades.Upgrades;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: yys
 * @Date: 2025/5/27
 */
@Slf4j
@RestController
@RequestMapping("init")
public class InitController {

    @GetMapping("/upgrade")
    public String upgrade() {
        log.info("start init");
        var db = DataDir.get().openDatabase(DerbyConfig.DBNAME);
        log.info("db version{}", db.getVersion());
        Upgrades.on(db);
        log.info("start finish");
        return "finish.";
    }

}
